<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Modules
 *
 * @author peerawatj20
 */
class home extends MY_Controller {

    public function index() {
        //Notice Item Below
        $this->load->model('notice_model');
        $item_below = $this->notice_model->find_item_below();
        $utility = new Config_utility();
        $str_alert = '';
        if (count($item_below) > 0) {
            $str_alert = '<h5><strong>สินค้าที่ใกล้หมดประจำวันที่' . $utility->convert_date(date("Y-m-d"), $utility->DAY) . "  " .
                    $utility->month_to_string($utility->convert_date(date("Y-m-d"), $utility->MONTH)) . "  " .
                    $utility->convert_date(date("Y-m-d"), $utility->YEAR) . '</strong></h5>';
            $str_alert .= '<ol>';
            foreach ($item_below as $item) {
                $str_alert .= '<li><h5>' . $item->stock_name . ' ' . ' คงเหลือ ' . $item->stock_qty . ' ' . $item->classifire . '</h5></li>';
            }
            $str_alert .= '</ol>';
        }
        $this->data['alert_item_below'] = $str_alert;
        //To page
        $this->load->view('main_modules', $this->data);
    }

}
